<template>
  <table class="table table-bordered table-stripped">
    <!-- 表格标题区域 -->
    <thead>
      <tr>
        <slot name="head"></slot>
      </tr>
    </thead>
    <!-- 表格主体区域 -->
    <tbody>
      <tr v-for="(good, i) in list" :key="i">
        <slot name="tr" :good="good"></slot>
      </tr>
    </tbody>
  </table>
</template>

<script>
export default {
  name: "MyTable",
  props: {
    // 表格数据数组
    list: {
      type: Array,
      required: true,
    },
  },
  methods: {
    doDel(id) {
      // a.根据id找下标
      const i = this.list.findIndex((e) => e.id === id);
      // b.根据下标 删除元素
      i && this.list.splice(i, 1);
    },
  },
};
</script>


<style scoped lang="less">
.my-goods-list {
  .badge {
    margin-right: 5px;
  }
}
</style>